cmake_minimum_required(VERSION 3.17)

file (GLOB COMMON_SOURCE_FILES "common/*.cc")
file (GLOB SERVER_SOURCE_FILES "server/*.cc")
file (GLOB CLIENT_SOURCE_FILES "client/*.cc")

include_directories(${PROJECT_ROOT_PATH}/include)

set(SOURCE_FILES
    ${COMMON_SOURCE_FILES}
    ${SERVER_SOURCE_FILES}
    ${CLIENT_SOURCE_FILES}
)

add_definitions(-DONLY_C_LOCALE=1)

find_package(Threads REQUIRED)

add_library(pistache SHARED ${SOURCE_FILES})
target_link_libraries(pistache PRIVATE Threads::Threads ${CMAKE_REQUIRED_LIBRARIES})

if (PISTACHE_USE_SSL)
    target_compile_definitions(pistache PUBLIC PISTACHE_USE_SSL)
    target_include_directories(pistache PRIVATE ${OPENSSL_INCLUDE_DIR})
    target_compile_definitions(pistache_shared PUBLIC PISTACHE_USE_SSL)
    target_link_libraries(pistache_shared PUBLIC OpenSSL::SSL OpenSSL::Crypto)
endif ()

